# frozen_string_literal: true

require 'colored2'
require 'claide'

module IosDev
  class Command < CLAide::Command
    include Config::Mixin

    require_relative 'command/keychain'
    require_relative 'command/cer'
    require_relative 'command/profile'
    require_relative 'command/xcodeproj'
    require_relative 'command/xcode'
    require_relative 'command/ipa'

    self.abstract_command = true
    self.command = 'ios_dev'
    self.version = VERSION
    self.description = 'a command line tool for iOS development'

    def self.options
      [
        ['--allow-root', 'Allows CocoaPods to run as root'],
        ['--silent', 'Show nothing'],
      ].concat(super)
    end

    def initialize(argv)
      super
      config.allow_root = argv.flag?('allow-root', false)
      config.silent = argv.flag?('silent', false)
      config.verbose = self.verbose? unless verbose.nil?

      unless self.ansi_output?
        Colored2.disable!
        String.send(:define_method, :colorize) { |string, _| string }
      end
    end
  end
end
